#!/bin/sh

usage() {
    echo "usage: $0 USER_FILE"
}

if [ $# -lt 1 ]; then
    usage
    exit 1
fi

while read line
do
    name=`echo $line | awk '{print $1}'`
    real_name=`echo $line | awk '{print $2}'`
    echo -n "正在为$real_name($name)创建用户"
    if `useradd -m $name>/dev/null 2>&1`; then
    	echo "\t成功"
    else
	echo "\t失败"
	continue
    fi

    passwd $name<<EOF
123456
123456
EOF
done < $1
